//
//  CYCompanyViewController.m
//  CaiYun
//
//  Created by 今日信息科技 on 2017/6/30.
//  Copyright © 2017年 今日信息科技. All rights reserved.
//

#import "CYCompanyViewController.h"
#import "CYWebViewController.h"
#import "CYUserBtn.h"
@interface CYCompanyViewController ()
/*官方applogo*/
@property (nonatomic, strong) CYImageView *logoImg;
/*扫描二维码*/
@property (nonatomic, strong) CYImageView *QRCodeImg;
/*提示扫描二维码的label*/
@property (nonatomic, strong) CYLabel *titleLbl;
/*官方网址*/
@property (nonatomic, strong) CYUserBtn *linkBtn;
/*在线客服*/
@property (nonatomic, strong) CYButton *serviceBtn;

@end

@implementation CYCompanyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.logoImg.hidden = self.linkBtn.hidden = self.QRCodeImg.hidden = self.titleLbl.hidden = self.serviceBtn.hidden = NO;
    
    // Do any additional setup after loading the view.
}

- (CYImageView *)logoImg{
    if (!_logoImg) {
        _logoImg = [[CYImageView alloc]initWithImageName:@"logo" radius:AL(10)];
        [self.view addSubview:_logoImg];
        
        WS(self)
        [_logoImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(weakSelf.view);
            make.top.equalTo(weakSelf.view).with.offset(NAVIBAR_HEIGHT + STATUS_HEIGHT + AL(PT(95)));
            make.size.mas_equalTo(CGSizeMake(AL(80), AL(80)));
        }];
    }
    return _logoImg;
}

- (CYUserBtn *)linkBtn{
    if (!_linkBtn) {
        _linkBtn = [[CYUserBtn alloc]initWithMainTitle:@"官方网址" secTitle:@"http://www-caiyun.com" mainFont:AL(PT(30)) secFont:AL(PT(26)) color:[UIColor blackColor] layout:mainTitleCenter];
        [_linkBtn addTarget:self action:@selector(actionForClickLinkBtn) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:_linkBtn];
        
        WS(self)
        [_linkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_logoImg.mas_bottom).with.offset(AL(PT(25)));
            make.centerX.equalTo(weakSelf.view);
            make.size.mas_equalTo(_linkBtn.bounds.size);
        }];
        
    }
    return _linkBtn;
}

- (CYImageView *)QRCodeImg{
    if (!_QRCodeImg) {
        _QRCodeImg = [[CYImageView alloc]initWithImageName:@"qrcode" radius:0.0];
        [self.view addSubview:_QRCodeImg];
        
        WS(self)
        [_QRCodeImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_linkBtn.mas_bottom).with.offset(AL(PT(75)));
            make.centerX.equalTo(weakSelf.view);
            make.size.mas_equalTo(CGSizeMake(AL(PT(310)), AL(PT(310))));
        }];
    }
    return _QRCodeImg;
}

- (CYLabel *)titleLbl{
    if (!_titleLbl) {
        _titleLbl = [[CYLabel alloc]initWithText:@"扫描二维码即可分享给好友" size:AL(PT(24)) textcolor:ColorHex(0x888888)];
        [self.view addSubview:_titleLbl];
        
        WS(self)
        [_titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_QRCodeImg.mas_bottom).with.offset(AL(PT(15)));
            make.centerX.equalTo(weakSelf.view);
            make.size.mas_equalTo(_titleLbl.bounds.size);
        }];
    }
    return _titleLbl;
}

- (CYButton *)serviceBtn{
    if (!_serviceBtn) {
        _serviceBtn = [[CYButton alloc]initWithTitle:@"在线客服" titleColor:ColorHex(0x0698fe) backgroundColor:[UIColor whiteColor] cornerRadius:0];
        [_serviceBtn addTarget:self action:@selector(actionForServiceBtn) forControlEvents:UIControlEventTouchUpInside];
        [_serviceBtn setImage:[UIImage imageNamed:@"service"] forState:UIControlStateNormal];
        [_serviceBtn setTitleColor:RGBA(8, 86, 122, 1) forState:UIControlStateHighlighted];
        [self.view addSubview:_serviceBtn];
        
        WS(self)
        [_serviceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(weakSelf.view.mas_bottom).with.offset(-  AL(PT(88)));
            make.centerX.equalTo(weakSelf.view);
            make.size.mas_equalTo(CGSizeMake(AL(100), AL(20)));
        }];
    }
    
    return _serviceBtn;
}

- (void)actionForServiceBtn{
    DeLog(@"点击在线客服");
    CYWebViewController *webVC = [[CYWebViewController alloc]init];
    webVC.title = @"客服";
    [self.navigationController pushViewController:webVC animated:YES];
    
}
- (void)actionForClickLinkBtn{
    DeLog(@"点击官方网址");
}
- (void)setupNavigationBarTintColor:(UIColor *)color{
    [super setupNavigationBarTintColor:color];
    self.navigationItem.title = @"关于我们";
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
